package com.lc.utils;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * Created by lichao on 2017/5/23.
 */
public class CommonConstant {
    private static ResourceBundle rb;

    static {
        rb = ResourceBundle.getBundle("props/lc");
    }

    public static String getValue(String key) {
        try {
            return rb.getString(key);
        } catch (MissingResourceException e) {
            return null;
        }
    }


    public static int getInt(String key) {
        return getInt(key, 0);
    }

    public static int getInt(String key, int def) {
        String val = getValue(key);
        int value = def;
        if (val != null) {
            value = Integer.valueOf(val);
        }
        return value;
    }

    /**
     * 获取项目版本信息
     * @return
     */
    public static String getProjectVersion() {
        return getValue("project.version");
    }
}